1 package org.smartcomps.twister.engine.core.dynamic; 2 3 import junit.framework.TestCase; 4 import org.smartcomps.twister.deployer.TwisterDeployer; 5 import org.smartcomps.twister.deployer.TwisterDeployerFactory; 6 import org.smartcomps.twister.common.lifecycle.LifecycleManager; 7 import org.smartcomps.twister.util.BeanTester; 8 import org.smartcomps.twister.engine.TwisterEngineFactory; 9 import org.smartcomps.twister.engine.priv.messaging.impl.DefaultMessageBrokerImpl; 10 import org.dom4j.Document; 11 import org.dom4j.DocumentHelper; 12 import net.sf.hibernate.tool.hbm2ddl.SchemaExport; 13 import net.sf.hibernate.cfg.Configuration; 14 15 public class TestFlow extends TestCase { 16 17 private TwisterDeployer deployer; 18 19 protected void setUp() throws Exception { 20 LifecycleManager.getLifecycleManager().createResources(); 21 LifecycleManager.getLifecycleManager().startResources(); 22 23 SchemaExport schemaExport = new SchemaExport(new Configuration().configure()); 24 schemaExport.create(true, true); 25 26 deployer = TwisterDeployerFactory.getTwisterDeployer(); 27 } 28 29 protected void tearDown() throws Exception { 30 LifecycleManager.getLifecycleManager().stopResources(); 31 LifecycleManager.getLifecycleManager().destroyResources(); 32 } 33 34 public void testExecuteWithDescription() throws Exception { 35 deployer.deploy(getClass().getClassLoader().getResource("test-flow.xml")); 36 37 // Starting the process. 38 Document doc = DocumentHelper.createDocument(); 39 doc.addElement("message").addElement("main").addElement("tstflowid") 40 .setText((String) BeanTester.generateRandomValue(String.class)); 41 int result = TwisterEngineFactory.getEngine().acknowledge("initiatingPartner", "initiatingPort", "initiatingOp", doc); 42 assertEquals("A problem occured when the message as been sent", 0, result); 43 44 Thread.sleep(10000); 45 46 // Checking that both branches have been executed 47 Document receivedDoc = DefaultMessageBrokerImpl.getMessage("firstBranchPartner", "firstBranchPort", "firstBranchOp"); 48 assertNotNull("Document received ", receivedDoc); 49 receivedDoc = DefaultMessageBrokerImpl.getMessage("secondBranchPartner", "secondBranchPort", "secondBranchOp"); 50 assertNotNull("Document received ", receivedDoc); 51 52 // Completing the first branch 53 result = TwisterEngineFactory.getEngine().acknowledge("firstBranchPartner", "firstBranchPort", "firstBranchOp", doc); 54 assertEquals("A problem occured when the message as been sent", 0, result); 55 56 Thread.sleep(10000); 57 58 // CHecking that everything is done 59 receivedDoc = DefaultMessageBrokerImpl.getMessage("lastPartner", "lastPort", "lastOp"); 60 assertNotNull("Document received ", receivedDoc); 61 } 62 63 }

This page was automatically generated by Maven